1. Field of the Invention
The present invention relates to computer operating systems. More specifically, the invention relates to a method of scheduling the use of a computer system resource according to a dynamically selectable allocation scheme.
2. Related Art
Today""s computer systems are relied upon to perform a variety of operations. Performance of the requested operations requires the use of various system resources (e.g., processor, memory, mass storage, network access). The busier the system (i.e., the more users connected to the system and the more processes or jobs running on the system), the greater the demand upon each such resource. Whenever more than one process or user at a time requires one of the computer""s resources, the resource must be shared between the requesting entities. Thus, some form of resource allocation and scheduling is needed.
Operating systems, which manage the allocation of a computer""s resources, share the usage of each resource among requesting entities in accordance with some pre-set scheme. For example, in a xe2x80x9cround-robinxe2x80x9d scheme the operating system divides usage of a resource by granting each requesting process full use of the resource for a relatively short period of time, and by rapidly switching use of the resource among all requesters. In an alternative scheme, requesting entities are grouped according to their associated priority. Those processes given relatively high priorities receive larger portions or more frequent use of the shared resource than processes assigned lower priorities.
Each of these schemes has disadvantages. For example, transferring use of a resource among numerous requesters in a round-robin scheme can be inefficient because during the time it takes to effect the transfer (commonly termed a xe2x80x9ccontext switchxe2x80x9d) the resource is not being productively used. The more frequently the resource is transferred, the less time it is actually in use and the lower its overall efficiency. A priority scheme may somewhat alleviate the waste of resource time inherent in context switches by providing for longer use of the resource in between transfers, but will be unfair to those requesters that must wait longer periods of time to use the resource.
The chosen method of sharing a resource among multiple requesters typically affects all system users, whether they interface directly with the operating system or operate within an application environment (e.g., a database management system (DBMS), a word processor, a modeling system). For example, instead of directly accessing the necessary computer resources to manage access to database tables on behalf of numerous users, a database management system typically calls upon the operating system to handle such access. Users within application environments are thus dependent upon the scheduling scheme implemented by the operating system, which may not provide the most efficient access to resources needed by those users. Because the operating system schedules use of all resources among all requesters according to a set scheme, an environment or process that would benefit from a different scheduling scheme suffers. The operating system""s method of allocating resources is not flexible enough, and usually cannot be customized, to provide for the optimal sharing of resources among all requesters.
In a large database management system, for example, which may have thousands of processes and jobs running to accomplish various tasks (e.g., retrieving data, storing data, generating a report), a scheduling scheme that attempts to give each job or process equal execution time by a processor can be particularly inefficient. With so many processes waiting to execute, the processor time wasted due to context switches becomes excessive. Similarly, attempting to control allocation of a processor""s execution time among DBMS users and processes according to a priority scheme does not provide very effective control of the processor""s time. The priority scheme merely allows one class of users or processes to be assigned a higher priority than another and thus receive faster or longer use of a resource. This scheme does not provide the ability to assign a particular class a set portion of processor execution time, thus preventing a database administrator from enabling the most effective control of resource allocation within the DBMS.
Relying upon the operating system""s method of resource allocation means that the allocation scheme for distributing resources within the computer system often cannot be dynamically altered according to the demands of system users and processes. In addition, the operating system is usually separate from application environments such as database management systems and therefore generally cannot know what, if any, inter-relationships exist between individual database users, processes and resources. Thus, the operating system may switch a first database process out of a processor while the process holds (i.e., has reserved or been assigned) a resource needed by a second database process. If the second process needs the resource in order to execute, then it is effectively blocked from executing until the first process relinquishes the resource, which may not occur until after the first process receives additional processor time. This situation is often termed xe2x80x9cdeadlock.xe2x80x9d In a priority-based allocation scheme where the first process mentioned above is at a lower priority than the second process, this may be termed xe2x80x9cpriority inversion.xe2x80x9d
As mentioned above, neither a priority-based scheduling scheme nor a round-robin scheme allows resources to be shared in a truly efficient manner. High priority processes are merely guaranteed to receive more of a resource than low priority processes. If processes or groups of processes could be accorded a particular percentage of a resource, system administrators would be able to allocate resources with much finer granularity. Further, the scheduling scheme implemented by an operating system is set at the time the operating system is loaded and begins executing. If a system manager or user wishes to implement a different scheduling scheme (whether for all or selected environments and processes), the operating system must be re-initialized or rebooted.
Thus, there is a need in the art for a method of allocating or scheduling resource usage that allows efficient resource sharing with minimal waste of the resource. Such a method will allow greater control over scheduling decisions by a system administrator. In particular, a need exists for a method of allocating resources according to ratios or percentages. A need also exists for a method of dynamically modifying a resource allocation plan without disrupting operation of a computer system or an application environment.
The present invention provides systems and methods for allocating a computer system resource among a plurality of resource requesters. In accordance with an embodiment of the invention, allocation of the resource is performed according to a dynamically selectable allocation scheme. Resource requesters in the present embodiment include processes, jobs, and other entities operating within a computer system and requiring use of a system resource. Computer system resources that may be allocated or shared among resource requesters illustratively include a processor, memory, mass storage and communication bandwidth.
In one embodiment of the present invention, a database management system (DBMS) is provided. A resource scheduler within the DBMS allocates a processor""s execution time (e.g., xe2x80x9cquantaxe2x80x9d) among various requesting DBMS processes and jobs that require execution time in order to accomplish DBMS users"" desired functions. The resource scheduler in this embodiment of the invention allocates processor time among classes of requesting processes and jobs according to dynamically selectable scheduling plans (e.g., during operation of the DBMS, the active scheduling plan can be changed). Scheduling plans in this embodiment comprise policies for allocating processor time between separate classes and/or among members of an individual class. The policy implemented by a scheduling plan is also dynamically selectable. Illustrative policies include round-robin, priority and emphasis policies.
In one embodiment of the invention, resource requesters are grouped into classes based on their requirements for the resource, as specified by a database administrator (DBA). For example, in one illustrative plan classes are established for different processing functions (e.g., processing electronic mail or fixing programming errors). In another illustrative plan, resource requesters are classified according to their mode of execution (e.g., on-line, batch). After constructing requester classes, the DBA groups the classes in one or more scheduling plans. Only one plan at a time is active during operation of the DBMS, but each plan can include one or more sub-plans. Each sub-plan includes classes of requesters. During operation of the DBMS, a class can only be a member of one active plan or sub-plan and is thus allocated processor time only within that plan or sub-plan. Within each plan and sub-plan, processor time is assigned to the participating classes based on an active policy.
In a present embodiment of the invention an xe2x80x9cemphasisxe2x80x9d policy is provided in which processor time is allocated among a plan""s classes and sub-plans by percentages. By adjusting the percentages, a DBA is able to increase or decrease the emphasis given to individual classes of resource requesters. In this embodiment, each plan and sub-plan implementing the emphasis policy is divided into multiple levels. Up to a maximum of 100% of the processor time available at a given level within a plan is distributed according to the percentages assigned to each class or sub-plan in the level. Thus, if 100% of processor time is allocated in the lowest, first level, classes in succeeding levels are shut out unless, as described below, a class is empty when its request for CPU time is granted.
One or more classes of resource requesters may participate in each level of a plan or sub-plan using the emphasis policy, and each class may participate in multiple levels of one plan or sub-plan. Processor time that is not allocated among the classes participating in the first level of a plan (or sub-plan) is available for allocation among the classes participating in subsequent levels. If processor time remains unallocated after being divided among the chosen number of levels, the remainder is recycled. In other words, after the total processor time is allocated among the classes participating in the first level of a plan, any processor time left over is allocated to the classes participating in the second level. Any processor time still remaining after allocation in the second level is carried over to the third level, and so on. Processor time left over after configuring the last level is distributed throughout the plan from the beginning.
Although only one scheduling plan is used at a time by the DBMS, multiple plans can be configured and stored, and the active plan can be changed at any time while the DBMS is running without restarting the operating system or DBMS. In a present embodiment, a plan may include one policy for allocating processor time between classes (e.g., the emphasis policy) and a separate policy for allocating processor time among the members of a single class (e.g., round-robin).
When operating conditions change (such as the composition of active DBMS users), a database administrator can activate one of the stored plans in place of the currently active plan. For example, the resource scheduler may first operate (e.g., during the business day) according to a plan that partitions processor time among classes of resource requesters according to the emphasis policy and a first set of percentages. Later, however (e.g., at night), a different plan may be implemented having the same classes but different percentages. Alternatively, the first scheduling plan may be changed to another plan in which processor time is allocated according to different classes or a different policy. In either event, the change in scheduling plan or policy can be made without restarting the DBMS.
In a current embodiment of the invention, one or more plans and policies are stored on the database system and a configuration file is maintained to indicate an active plan and policy from among those stored on the system. Illustratively, the configuration file includes one or more indicators to represent the particular plan and policy that is to be implemented at a given time. The resource scheduler accesses the configuration file to determine the active plan and policy before allocating the processor. In one embodiment, if no active plan or policy is indicated by the configuration file, the resource scheduler allocates the processor according to a scheme implemented by the database server operating system.